package com.supermarket.demo1.mapper;


import com.supermarket.demo1.pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {
    @Select("SELECT * FROM smbms_user where userCode = #{userCode} and userPassword = #{userPassword}")
    public List<User> getUserByUser(User user);

    /**
     * 根据userCode查询指定用户
     * @param userCode
     * @return
     */
    @Select("select * from smbms_user where userCode = #{userCode}")
    User selectUserByName(@Param("userCode") String userCode);

    // 查询全部用户
    @Select("select * from smbms_user")
    public List<User> getAllUser();


    //分页获取用户信息
    // no:页面
    // size:大小
    public List<User> getUserByNo(int no, int size);

    /**
     * 根据用户id删除指定用户
     * @param id
     * @return
     */
    @Delete("delete from smbms_user where id = #{id}")
    public int deleteUser(@Param("id") int id);

}
